#include <bits/stdc++.h>
using namespace std;
const int N = 10010000;
int n, k;
char b[N];
struct s{
	int a, b, c, d;
	bool operator < (const s &t)const{
		return abs(c - d) < abs(t.c - t.d);
	}
}f[N];
struct node{
	int o, e;
}a[N];
void ad(int l)
{
	for(int i = l + 2; i <= n; i++){
		a[i - 2] = a[i];
		b[i - 2] = b[i];
	}
}
int main()
{
	cin >> n;
	for(int i = 1; i <= n; i++)
		cin >> b[i];
	for(int i = 1; i <= n; i++){
		cin >> a[i].e;
		a[i].o = i;
	}
	
	for(int i = 1; i <= n;)
	{
		if(b[i] == 'B' && b[i+1] == 'G')
		{
			++k;
			f[k].a = a[i + 1].o;
			f[k].b = a[i].o;
			f[k].c = a[i + 1].e;
			f[k].d = a[i].e;
			ad(i);
			n -= 2;
			i = 1;
		} 
		else if(b[i] == 'G' && b[i+1] == 'B')
		{
			++k;
			f[k].a = a[i].o;
			f[k].b = a[i + 1].o;
			f[k].c = a[i].e;
			f[k].d = a[i + 1].e;
			ad(i);
			n -= 2;
			i = 1;
		}
		else
			i++;
	}

	sort(f + 1, f + 1 + k);
	cout << k << endl;
	for(int i = 1; i <= k; i++){
		if(min(f[i].a, f[i].b) == f[i].a)
			cout << f[i].a << " " << f[i].b << endl;
		else
			cout << f[i].b << " " << f[i].a << endl;
	}
	return 0;
}
/*
4
BGBG
4 2 4 3
*/